<?php

namespace app\wachat\controller;

class Ucase extends Base
{
    protected $beforeActionList = [
//        'right' => ['only' => 'index,detailed'],
        'images' => ['only' => 'detailed'],
        'uclass'=>['only'=>'index,detailed'],
    ];

    /**
     * 更多图片
     */
    public function images()
    {
        $images = model('UcaseImages')->where('pid', $this->request->param('id'))->column('image');
        $this->assign([
            'images' => $images,
        ]);
    }

    /**
     * 案例列表
     */
    public function uclass(){
        $data['model']='Ucase';
        $data['status']=1;
        $data['lang']=cookie('think_var');
        $uclass= model('nav')->where($data)->select();
        $this->assign('uclass',$uclass);
        return $uclass;
    }

    public function all(){
            $dd = $this->uclass();
            /*列表start*/
            $list = db('Ucase')->alias('a')
                ->join('__NAV__ c', 'c.id= a.cid')
                ->field('a.*,c.name,c.model')
                ->where('c.status', '1')
                ->where('a.status', '1')
                ->paginate()
                ->appends($this->request->param());
            $this->assign('list', $list);
            /*列表end*/
            return $this->fetch($this->template . $dd[0]['templist']);

        /*模板end*/
    }


    public function detailed($id)
    {
        $data= model('Ucase')->get($id);
        //更多图片
        $data['images'] = model('UcaseImages')->where('pid', $data['id'])->field('image')->select();
        $next = model('Ucase')->getnext($id);
        $resulr = [
            'data'=> $data,
            'next'=> $next,
        ];
        echo json_encode($resulr);
        exit();
        $this->assign([
           'data'=> $data,
           'next'=> $next,
        ]);
        return $this->fetch();
    }
}
